//
//  Shops.m
//  瀑布流布局
//
//  Created by 红蜀黍 on 15/5/6.
//  Copyright (c) 2015年 红蜀黍. All rights reserved.
//

#import "Shops.h"

@implementation Shops

+ (instancetype)shopWithDictionary:(NSDictionary *)dict
{
    id obj = [[self alloc] init];
    
    [obj setValuesForKeysWithDictionary:dict];
    return obj;
}


+ (NSArray *)shopWithIndex:(NSInteger)index
{
    // 通过路径把文件加载到数组
    NSString *fileName = [NSString stringWithFormat:@"%zd.plist",(index % 3)+1];
    NSString *path = [[NSBundle mainBundle] pathForResource:fileName ofType:nil];
    NSArray *array = [NSArray arrayWithContentsOfFile:path];
    
    NSMutableArray *arrM = [NSMutableArray arrayWithCapacity:array.count];
    // 遍历数组
    [array enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
        [arrM addObject:[self shopWithDictionary:obj]];
    }];
    
    return arrM.copy;
}

@end
